home *** CD-ROM | disk | FTP | other *** search
/ PC Users 1999 April / Cd Pc Users extra 19 abril 1999.iso / Prog / Inst / Js02 / js02.exe / js / livebutton.js < prev    next >
Encoding:
Text File  |  1999-02-15  |  12.3 KB  |  293 lines

  1. function Create_Button(signe_browser,NameId,NbButton,LeftPos,TopPos,ImWidth,ImHeight,signe_ver){
  2.     var meja=null;
  3.     var LiveButton='';
  4.     var LiveButton1='';
  5.     var LiveButton2='';
  6.     var LiveButton3='';
  7.     var LiveButtonSelect1='';
  8.     var LiveButtonSelect2='';
  9.     var LiveButtonNav1='';
  10.     var LiveButtonNav2='';
  11.     var LiveButtonForm='';
  12.     var LiveButtonFormDiv='';
  13.     var NewFrame='';
  14.     var LiveRef='<BASE HREF="http://www.buana.com/content/">   \n';
  15.     TopPos=TopPos+30;
  16.     
  17.     LiveButton1  ='<HTML>   \n';
  18.     LiveButton1 +='<TITLE>Live Button: CROSS BROWSER DHTML/JAVASCRIPT: VERSION 1.00</TITLE>   \n';
  19.     LiveButton1 +='<HEAD>   \n';
  20.  
  21.     LiveButton1 +='<STYLE TYPE="text/css">  \n';    
  22.     LiveButton1 +='BODY {background: url(../image/snm_bgsawo.jpg); background-position: -120 0;}   \n';    
  23.     LiveButton1 +='#'+NameId+' {visibility:inherit; position:absolute; LEFT:'+LeftPos+ '; TOP:'+TopPos+ ';}  \n';
  24.  
  25.     for (var j=1; j<NbButton; j++){
  26.  
  27.  
  28.  
  29.  
  30.  
  31.         if (signe_ver==1){
  32.             var ImHeight1=(j-1)*ImHeight;
  33.             LiveButton1 +='#'+NameId+'menu'+j+' {position:absolute; LEFT:0; TOP:'+ImHeight1+ ';}  \n';
  34.         }
  35.         if (signe_ver==0){
  36.             var ImWidth1=(j-1)*ImWidth;
  37.             LiveButton1 +='#'+NameId+'menu'+j+' {position:absolute; LEFT:'+ImWidth1+ '; TOP:0;}  \n';
  38.         }
  39.     }
  40.     LiveButton1 +='</STYLE>   \n';
  41.  
  42.     LiveButton1 +='<SCRIPT LANGUAGE="javascript" SRC="../jscripts/initv01.js"></SCRIPT>  \n';
  43.     LiveButton1 +='<SCRIPT LANGUAGE="javascript" SRC="../jscripts/liveim2v01.js"></SCRIPT>  \n';
  44.     LiveButton1 +='<SCRIPT LANGUAGE="JavaScript" SRC="../jscripts/browser01.js"></SCRIPT>  \n';
  45.     LiveButton1 +='<SCRIPT LANGUAGE="JavaScript">  \n';
  46.     LiveButton1 +='var nbrowser=-1;  \n';
  47.  
  48.     for (var j=1; j <NbButton; j++){
  49.  
  50.         LiveButton1 +='     // \n';
  51.         LiveButton1 +='     // Button N0: '+j+' \n';
  52.         LiveButton1 +='     // \n';
  53.  
  54.         LiveButton1 +='    '+NameId+'img'+j+''+j+'click = new Image();  \n';
  55.         LiveButton1 +='    '+NameId+'img'+j+''+j+'over = new Image();  \n';
  56.         LiveButton1 +='    '+NameId+'img'+j+''+j+'out = new Image();  \n';
  57.  
  58.  
  59.         LiveButton1 +='    '+NameId+'img'+j+''+j+'click.src = "../image/snm_btonline_click.gif";  \n';
  60.         LiveButton1 +='    '+NameId+'img'+j+''+j+'over.src = "../image/snm_btonline_over.gif";  \n';
  61.         LiveButton1 +='    '+NameId+'img'+j+''+j+'out.src = "../image/snm_btonline.gif";  \n';
  62.     }
  63.  
  64.     LiveButton1 +='function check_browser(){  \n';
  65.     LiveButton1 +='    get_browser();  \n';
  66.     LiveButton1 +='    if (browser.name ==  "Microsoft Internet Explorer")   nbrowser=1;  \n';
  67.     LiveButton1 +='    if (browser.name ==  "Navigator Netscape") nbrowser=0;  \n';
  68.     LiveButton1 +='}  \n';
  69.     LiveButton1 +='function '+NameId+'_over(k){  \n';
  70.     LiveButton1 +='    var lay2="'+NameId+'menu"+k;  \n';
  71.     LiveButton1 +='    var imlay2="'+NameId+'img"+k;  \n';
  72.     LiveButton1 +='    img_over2(nbrowser,"'+NameId+'",lay2,imlay2,k);  \n';
  73.     LiveButton1 +='    End'+NameId+'_over(k);  \n';
  74.     LiveButton1 +='}  \n';
  75.     LiveButton1 +='function '+NameId+'_out(k){  \n';
  76.     LiveButton1 +='    var lay2="'+NameId+'menu"+k;  \n';
  77.     LiveButton1 +='    var imlay2="'+NameId+'img"+k;  \n';
  78.     LiveButton1 +='    img_out2(nbrowser,"'+NameId+'",lay2,imlay2,k);  \n';
  79.     LiveButton1 +='    End'+NameId+'_out(k);  \n';
  80.     LiveButton1 +='}  \n';
  81.     LiveButton1 +='function '+NameId+'_click(k){  \n';
  82.     LiveButton1 +='    var lay2="'+NameId+'menu"+k;  \n';
  83.     LiveButton1 +='    var imlay2="'+NameId+'img"+k;  \n';
  84.     LiveButton1 +='    img_click2(nbrowser,"'+NameId+'",lay2,imlay2,k);  \n';
  85.     LiveButton1 +='    End'+NameId+'_click(k);  \n';
  86.     LiveButton1 +='}  \n';
  87.     
  88.     LiveButton1 +='//---------------------------------------------------------   \n';
  89.     LiveButton1 +='// Create Your Own Function Into These Following Functions.  \n';
  90.     LiveButton1 +='// k is Number Of Your Related Button.  \n';
  91.     LiveButton1 +='// Look this Exemple: \n';
  92.     LiveButton1 +='//     function EndLiveButtonIE1_click(k){   \n';
  93.     LiveButton1 +='//         if (k==1) location.href="myhtml1.html" \n';
  94.     LiveButton1 +='//         if (k==2) location.href="myhtml2.html" \n';
  95.     LiveButton1 +='//        } \n';
  96.     LiveButton1 +='//---------------------------------------------------------   \n';
  97.  
  98.     LiveButton1 +='function End'+NameId+'_over(k){}  \n';
  99.     LiveButton1 +='function End'+NameId+'_out(k){}  \n';
  100.     LiveButton1 +='function End'+NameId+'_click(k){}  \n';
  101.     LiveButton1 +='</SCRIPT>  \n';
  102.  
  103.     LiveButton2 ='</HEAD>  \n';
  104.     LiveButton2 +='<BODY>  \n';
  105.     LiveButton2 +='<DIV ID='+NameId+'>  \n';
  106.  
  107.     for (var j=1; j<NbButton; j++){
  108.  
  109.         LiveButton2 +='    <DIV ID='+NameId+'menu'+j+'>  \n';
  110.         LiveButton2 +='    <A HREF="javascript://" OnMouseOver="'+NameId+'_over('+j+')" OnMouseout="'+NameId+'_out('+j+')" OnClick="'+NameId+'_click('+j+'); return false;">  \n';
  111.         LiveButton2 +='    <IMG BORDER=0 NAME='+NameId+'img'+j+' SRC="../image/snm_btonline.gif"></A> \n';
  112.         LiveButton2 +='    </DIV>  \n';
  113.     }
  114.  
  115.     LiveButton2 +='</DIV>  \n';
  116.     LiveButton3  ='</BODY>  \n';
  117.     LiveButton3 +='</HTML>  \n';
  118.     LiveButton3 +='<SCRIPT>var tc=check_browser();</SCRIPT>  \n';
  119.  
  120.     LiveButtonSelect1  ='<SCRIPT LANGUAGE="JavaScript" SRC="../jscripts/objvisv01.js"></SCRIPT>  \n';
  121.     LiveButtonSelect1 +='<SCRIPT LANGUAGE="javascript" SRC="../jscripts/liveim2v01.js"></SCRIPT>  \n';
  122.     LiveButtonSelect1 +='<SCRIPT LANGUAGE="javascript">  \n';
  123.     LiveButtonSelect1 +='//  \n';
  124.     LiveButtonSelect1 +='// IMAGE SETUP FOR SELECTS BUTTON  \n';
  125.     LiveButtonSelect1 +='//  \n';
  126.     LiveButtonSelect1 +='SELECT1img1click = new Image();  \n';
  127.     LiveButtonSelect1 +='SELECT1img1click.src = "../image/snm_code_click.gif";  \n';
  128.     LiveButtonSelect1 +='SELECT1img1over = new Image();  \n';
  129.     LiveButtonSelect1 +='SELECT1img1over.src = "../image/snm_code_over.gif";  \n';
  130.     LiveButtonSelect1 +='SELECT1img1out = new Image();  \n';
  131.     LiveButtonSelect1 +='SELECT1img1out.src = "../image/snm_code.gif";  \n';
  132.     LiveButtonSelect1 +='//  \n';
  133.     LiveButtonSelect1 +='SELECT2img2click = new Image();  \n';
  134.     LiveButtonSelect1 +='SELECT2img2click.src = "../image/snm_preview_click.gif";  \n';
  135.     LiveButtonSelect1 +='SELECT2img2over = new Image();  \n';
  136.     LiveButtonSelect1 +='SELECT2img2over.src = "../image/snm_preview_over.gif";  \n';
  137.     LiveButtonSelect1 +='SELECT2img2out = new Image();  \n';
  138.     LiveButtonSelect1 +='SELECT2img2out.src = "../image/snm_preview.gif";  \n';
  139.     LiveButtonSelect1 +='//  \n';
  140.     LiveButtonSelect1 +='SELECT3img3click = new Image();  \n';
  141.     LiveButtonSelect1 +='SELECT3img3click.src = "../image/snm_back_click.gif";  \n';
  142.     LiveButtonSelect1 +='SELECT3img3over = new Image();  \n';
  143.     LiveButtonSelect1 +='SELECT3img3over.src = "../image/snm_back_over.gif";  \n';
  144.     LiveButtonSelect1 +='SELECT3img3out = new Image();  \n';
  145.     LiveButtonSelect1 +='SELECT3img3out.src = "../image/snm_back.gif";  \n';
  146.     LiveButtonSelect1 +='function select_over(k){  \n';
  147.     LiveButtonSelect1 +='    ly1="SELECT";  \n';
  148.     LiveButtonSelect1 +='    ly2="SELECT"+k;  \n';
  149.     LiveButtonSelect1 +='    Img=ly2+"img";  \n';
  150.     LiveButtonSelect1 +='    img_over2(nbrowser,ly1,ly2,Img,k);  \n';
  151.     LiveButtonSelect1 +='}  \n';
  152.     LiveButtonSelect1 +='function select_out(k){  \n';
  153.     LiveButtonSelect1 +='    ly1="SELECT";  \n';
  154.     LiveButtonSelect1 +='    ly2="SELECT"+k;  \n';
  155.     LiveButtonSelect1 +='    Img=ly2+"img";  \n';
  156.     LiveButtonSelect1 +='    img_out2(nbrowser,ly1,ly2,Img,k);  \n';
  157.     LiveButtonSelect1 +='}  \n';
  158.     LiveButtonSelect1 +='function select_click(k){  \n';
  159.     LiveButtonSelect1 +='    ly1="SELECT";  \n';
  160.     LiveButtonSelect1 +='    ly2="SELECT"+k;  \n';
  161.     LiveButtonSelect1 +='    Img=ly2+"img";  \n';
  162.     LiveButtonSelect1 +='    img_click2(nbrowser,ly1,ly2,Img,k);  \n';
  163.  
  164.     LiveButtonSelect1 +='    if (k==3) parent.frames[1].history.go(-1);  \n';
  165.     LiveButtonSelect1 +='    if (k==1) Obj_Vis(nbrowser,1,"'+NameId+'","hidden");  \n';
  166.     LiveButtonSelect1 +='    if (k==1) Obj_Vis(nbrowser,1,"SOURCE","inherit");  \n';
  167.  
  168.     LiveButtonSelect1 +='    if (k==2) Obj_Vis(nbrowser,1,"SOURCE","hidden");  \n';
  169.     LiveButtonSelect1 +='    if (k==2) Obj_Vis(nbrowser,1,"'+NameId+'","inherit");  \n';
  170.     LiveButtonSelect1 +='}  \n';
  171.     LiveButtonSelect1 +='</SCRIPT>  \n';
  172.     
  173.     LiveButtonSelect2  ='<DIV ID=SELECT STYLE="position:absolute; left:10; top:0;">  \n';
  174.     LiveButtonSelect2 +='    <DIV ID=SELECT1 STYLE="position:absolute; left:20; top:0;">  \n';
  175.     LiveButtonSelect2 +='        <A HREF="javascript://"  \n';
  176.     LiveButtonSelect2 +='        OnMouseOver="select_over(1)"  \n';
  177.     LiveButtonSelect2 +='        OnMouseOut="select_out(1)"  \n';
  178.     LiveButtonSelect2 +='        OnClick="select_click(1); return false;">  \n';
  179.     LiveButtonSelect2 +='        <IMG BORDER=0 NAME=SELECT1img SRC="../image/snm_code.gif"></A>  \n';
  180.     LiveButtonSelect2 +='    </DIV>  \n';
  181.     LiveButtonSelect2 +='    <DIV ID=SELECT2 STYLE="position:absolute; left:120; top:0;">  \n';
  182.     LiveButtonSelect2 +='        <A HREF="javascript://"  \n';
  183.     LiveButtonSelect2 +='        OnMouseOver="select_over(2)"  \n';
  184.     LiveButtonSelect2 +='        OnMouseOut="select_out(2)"  \n';
  185.     LiveButtonSelect2 +='        OnClick="select_click(2); return false;">  \n';
  186.     LiveButtonSelect2 +='        <IMG BORDER=0 NAME=SELECT2img SRC="../image/snm_preview.gif"></A>  \n';
  187.     LiveButtonSelect2 +='    </DIV>  \n';
  188.     LiveButtonSelect2 +='    <DIV ID=SELECT3 STYLE="position:absolute; left:220; top:0;">  \n';
  189.     LiveButtonSelect2 +='        <A HREF="javascript://"  \n';
  190.     LiveButtonSelect2 +='        OnMouseOver="select_over(3)"  \n';
  191.     LiveButtonSelect2 +='        OnMouseOut="select_out(3)"  \n';
  192.     LiveButtonSelect2 +='        OnClick="select_click(3); return false;">  \n';
  193.     LiveButtonSelect2 +='        <IMG BORDER=0 NAME=SELECT3img SRC="../image/snm_back.gif"></A>  \n';
  194.     LiveButtonSelect2 +='    </DIV>  \n';
  195.     LiveButtonSelect2 +='</DIV>  \n';
  196.  
  197.     screen_width();
  198.  
  199.     if (MyScreenWidth==800) {
  200.         var MyRows=16;
  201.         var MyCols=50;
  202.     }else{
  203.         var MyRows=12;
  204.         var MyCols=38;
  205.     }
  206.  
  207.     LiveButtonForm  ='    <FORM NAME=test> \n';
  208.     LiveButtonForm +='        <TEXTAREA NAME=test2 name=output  ROWS='+MyRows+' COLS='+MyCols+'> \n';
  209.     LiveButtonForm +=LiveRef+LiveButton1+LiveButton2+LiveButton3;
  210.     LiveButtonForm +='        </TEXTAREA> \n';
  211.     LiveButtonForm +='    </FORM > \n';
  212.  
  213.     LiveButtonFormDiv  ='<DIV ID=SOURCE STYLE="visibility:hidden; position:absolute; left:10; top:30;"> \n';
  214.     LiveButtonFormDiv +=LiveButtonForm;
  215.     LiveButtonFormDiv +='</DIV> \n';
  216.  
  217.  
  218.  
  219.     if (signe_browser==1){
  220.  
  221.         LiveButton=LiveButton1+LiveButtonSelect1+LiveButton2+LiveButtonSelect2+LiveButtonFormDiv+LiveButton3;
  222.  
  223.  
  224.         // meja=window.open("","online","width=580,height=380,left=0,top=0,menubar=yes");
  225.         // meja.document.write(LiveButton);
  226.         // meja.document.close();
  227.         // meja.focus();
  228.  
  229.         parent.frames[1].document.write(LiveButton);
  230.         parent.frames[1].document.close();
  231.  
  232.  
  233.     }
  234.  
  235.     if (signe_browser==0){
  236.  
  237.  
  238.         Obj_Vis(nbrowser,1,'CONTENT','hidden');
  239.  
  240.         document.SOURCE.document.open();
  241.         document.SOURCE.document.write(LiveButtonForm);
  242.         document.SOURCE.document.close();
  243.  
  244.         NameId='MyFunction';
  245.  
  246.  
  247.         LiveButtonNav1 ='<DIV ID='+NameId+' STYLE="position:absolute; LEFT:'+LeftPos+ '; TOP:'+TopPos+ ';">  ';
  248.  
  249.         for (var j=1; j<NbButton; j++){
  250.  
  251.             if (signe_ver==1){
  252.                 var ImHeight1=(j-1)*ImHeight;
  253.                 LiveButtonNav2 =' position:absolute; LEFT:0; TOP:'+ImHeight1+';' ;
  254.             }
  255.             if (signe_ver==0){
  256.                 var ImWidth1=(j-1)*ImWidth;
  257.                 LiveButtonNav2 =' position:absolute; LEFT:'+ImWidth1+ '; TOP:0;';
  258.             }
  259.  
  260.             LiveButtonNav1 +='    <DIV ID='+NameId+'menuClick'+j+' STYLE="'+LiveButtonNav2+'">  ';
  261.             LiveButtonNav1 +='    <A HREF="javascript://" OnMouseOver="'+NameId+'_over('+j+')" OnMouseout="'+NameId+'_out('+j+')" OnClick="'+NameId+'_click('+j+'); return false;">  ';
  262.             LiveButtonNav1 +='    <IMG BORDER=0 NAME='+NameId+'img SRC="../image/snm_btonline_click.gif"></A> ';
  263.             LiveButtonNav1 +='    </DIV>  ';
  264.  
  265.  
  266.             LiveButtonNav1 +='    <DIV ID='+NameId+'menuOver'+j+' STYLE="'+LiveButtonNav2+'">  ';
  267.             LiveButtonNav1 +='    <A HREF="javascript://" OnMouseOver="'+NameId+'_over('+j+')" OnMouseout="'+NameId+'_out('+j+')" OnClick="'+NameId+'_click('+j+'); return false;">  ';
  268.             LiveButtonNav1 +='    <IMG BORDER=0 NAME='+NameId+'img SRC="../image/snm_btonline_over.gif"></A> ';
  269.             LiveButtonNav1 +='    </DIV>  ';
  270.  
  271.             LiveButtonNav1 +='    <DIV ID='+NameId+'menuOut'+j+' STYLE="'+LiveButtonNav2+'">  ';
  272.             LiveButtonNav1 +='    <A HREF="javascript://" OnMouseOver="'+NameId+'_over('+j+')" OnMouseout="'+NameId+'_out('+j+')" OnClick="'+NameId+'_click('+j+'); return false;">  ';
  273.             LiveButtonNav1 +='    <IMG BORDER=0 NAME='+NameId+'img SRC="../image/snm_btonline.gif"></A> ';
  274.             LiveButtonNav1 +='    </DIV>  ';
  275.  
  276.         }
  277.  
  278.         LiveButtonNav1 +='</DIV>  ';
  279.  
  280.  
  281.         document.PREVIEW.document.open();
  282.         document.PREVIEW.document.write(LiveButtonNav1);
  283.         document.PREVIEW.document.close();
  284.  
  285.         Obj_Vis(nbrowser,1,'SELECT','inherit');
  286.         Obj_Vis(nbrowser,1,'PREVIEW','inherit');
  287.         window.scroll(0,0);
  288.  
  289.  
  290.     }
  291.  
  292. }
  293.